#!/bin/sh
source /etc/os-release
if [ "$ID" = "openmptcprouter" ]; then
	cat > "/etc/opkg/customfeeds.conf" <<-EOF
	    src/gz openwrt_luci https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/luci
	    src/gz openwrt_packages https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/packages
	    src/gz openwrt_base https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/base
	    src/gz openwrt_routing https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/routing
	    src/gz openwrt_telephony https://packages.openmptcprouter.com/${VERSION_ID}/${OPENWRT_ARCH}/telephony
	EOF
	TARGET="$(cat /etc/banner | awk '/TARGET/ {print $2}')"
	cat > "/etc/opkg/distfeeds.conf" <<-EOF
	    src/gz openmptcprouter_core https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/targets/${OPENWRT_BOARD}/packages
	    src/gz openmptcprouter_base https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/base
	    src/gz openmptcprouter_luci https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/luci
	    src/gz openmptcprouter_openmptcprouter https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/openmptcprouter
	    src/gz openmptcprouter_packages https://download.openmptcprouter.com/release/${VERSION_ID}/${TARGET}/packages/${OPENWRT_ARCH}/packages
	EOF
fi